package cn.snmp.mutual.nms.mibs;

import java.io.*;
import java.util.*;

class RangeList implements Cloneable, Serializable
{
    boolean isRanged;
    boolean isEnumerated;
    Vector vRanges;
    Hashtable htEnum;
    
    public RangeList(final Vector vRanges) {
        this.isRanged = true;
        this.vRanges = vRanges;
    }
    
    public RangeList(final Hashtable htEnum) {
        this.isEnumerated = true;
        this.htEnum = htEnum;
    }
    
    @Override
    public String toString() {
        final StringBuffer stringbuffer = new StringBuffer();
        if (this.isRanged && this.vRanges != null) {
            stringbuffer.append(" ( size ( ");
            for (int i = 0; i < this.vRanges.size(); ++i) {
                stringbuffer.append(this.vRanges.get(i));
                if (i < this.vRanges.size() - 1) {
                    stringbuffer.append("| ");
                }
            }
            stringbuffer.append(" ) ) ");
            return stringbuffer.toString().replace("  ", " ");
        }
        if (this.isEnumerated && this.htEnum != null) {
            stringbuffer.append(" { ");
            final Enumeration e = this.htEnum.keys();
            while (e.hasMoreElements()) {
                final Object Label = e.nextElement();
                stringbuffer.append(Label + " ( " + this.htEnum.get(Label) + " ) ");
                if (e.hasMoreElements()) {
                    stringbuffer.append(", ");
                }
            }
            stringbuffer.append("} ");
            return stringbuffer.toString().replace("  ", " ");
        }
        return "";
    }
}
